package com.meteor.admin.dto;


import lombok.Data;

/**
 * 请求返回对象
 */
@Data
public class ResponseDTO<T> {

    public static final int OK_CODE = 0;
    public static final int ERROR_CODE = 500;

    public static final String OK_MSG = "操作成功";

    private Integer code;

    private String msg;

    private T data;

    public ResponseDTO(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResponseDTO<T> ok() {
        return new ResponseDTO<>(OK_CODE, OK_MSG, null);
    }

    public static <T> ResponseDTO<T> ok(T data) {
        return new ResponseDTO<>(OK_CODE, OK_MSG, data);
    }

    public static <T> ResponseDTO<T> error(String msg) {
        return new ResponseDTO<>(ERROR_CODE, msg, null);
    }

}
